<template>
  <div class="user-container">
    <h3 class="title">用户中心</h3>
    <div class="touxiang">
      <img :src="user.headportrait_url" alt="">
    </div>
    <div class="msg">
      <p>昵称：{{user.username}}</p>
      <p>账号：{{user.account}}</p>
      <p>状态：已登陆</p>
      <router-link to="/user/login" class="to-login">重新登录</router-link>
      <span class="exit" @click="exit()">退出登录</span>
      <router-link to="/user/updataUser" class="to-login">修改资料</router-link>
    </div>
  </div>
</template>
<script>
export default {
  data(){
    return{
      user:{...this.$store.state.user.user}
    }
  },
  created(){
    if(!localStorage.getItem('token')){
      this.$router.push('/user/login')
    }
  },
  methods:{
    exit(){
      localStorage.setItem("token","")
      this.$router.push('/user/login')
    }
  }
}
</script>

<style lang="less" scoped>
.user-container{
  padding: 20px;
  .title{
    text-align: center;
  }
  .touxiang{
    background-image: url('../../img/none.png') ;
    background-size:100% ;
    width: 60px;
    height: 60px;
    border-radius:50% ;
    img{
      width: 60px;
      height: 60px;
    }
    margin-top:10%
  }
  .exit{
    color: blue;
  }
  .msg{
    margin-top: 20px;
  }
}
</style>